/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cc.uah.es.snomedctsubsetextractor;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

/**
 *
 * @author torry
 */
public class SNOMEDCTConfigurator {

    private Element root;

    public SNOMEDCTConfigurator(String configurationFile) {
        try {
            File confFile = new File(configurationFile);
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(confFile);
            this.root = doc.getRootElement();
        } catch (JDOMException ex) {
            Logger.getLogger(SNOMEDCTConfigurator.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(SNOMEDCTConfigurator.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    public String getValue(String key) {

        List<Element> namespaces = this.root.getChildren("param");

        String value = null;

            for (Element namespace : namespaces) {
                if( key.equalsIgnoreCase(namespace.getChild("key").getTextTrim()))
                    value = namespace.getChild("value").getTextTrim();
            }
            return value;
    }

    public void setValue(String nameValue, String uriValue) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
